package cn.calm.linksource.action;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.apache.struts2.osgi.interceptor.ServiceAware;

import cn.calm.commons.action.CurdAction;
import cn.calm.commons.entity.PageMode;
import cn.calm.entity.LinkSource;
import cn.calm.linksource.service.ILinkSourceService;

@SuppressWarnings("rawtypes")
public class LinkSourceAction<T extends LinkSource, S extends ILinkSourceService<T>>
		extends CurdAction<T, S> implements ServiceAware<ILinkSourceService> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public String getModeName() {
		return "linkSource";
	}

	@Override
	public List<T> getList() {
		return super.getList();
	}

	@Override
	public Map<String, List<String>> getFieldErrors() {
		return super.getFieldErrors();
	}

	@Override
	public Collection<String> getActionErrors() {
		return super.getActionErrors();
	}

	@Override
	public T getT() {
		return super.getT();
	}

	@Override
	public PageMode getPageMode() {
		return super.getPageMode();
	}

	@SuppressWarnings("unchecked")
	@Override
	public Class<T> getEntityClass() {
		return (Class<T>) LinkSource.class;
	}

	@SuppressWarnings("unchecked")
	@Override
	public void setServices(List<ILinkSourceService> arg0) {
		if (service == null) {
			if (arg0 != null && arg0.size() > 0) {
				service = (S) arg0.get(0);
			}
		}
	}
}
